#include "omp.h"
#include <iostream>
#include <vector>

using namespace std;

int main() {
    omp_set_num_threads(40);
    omp_lock_t lck;
    omp_init_lock(&lck);
    int tmp, id;
#pragma omp parallel private(tmp, id)
    {
        id = omp_get_thread_num();
        tmp = id + 1;
//        omp_set_lock(&lck);
/*
 * 每当上锁时只有一个线程能进来
 */
        printf("this is a lock %d %d\n", id, tmp);
//        omp_unset_lock(&lck);
    }
    omp_destroy_lock(&lck);
    return 0;
}